home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARSRC21.ZIP / AR256H5.CPP < prev    next >
C/C++ Source or Header  |  1995-06-02  |  24KB  |  948 lines

  1. // Main file of 2nd module
  2. // this module contains frontend, ending, and tweenturns
  3. // ar256ex is externals that were declared in ar256
  4. // ar256def is defs of mouse and screenmsgs
  5. // ar245h is defs of sqare and monster
  6.  
  7.  
  8.  
  9.  
  10. // frontend
  11.  
  12. #include <dos.h>
  13. #include<process.h>
  14. #include <graphics.h>
  15. #include <string.h>
  16. #include <conio.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <math.h>
  20.  
  21. #include "ar256h.cpp"
  22. enum tf {true,false};
  23. //#include "ar256m.cpp"
  24. #include "svga256.h"
  25. #include"ar256def.h"
  26.  
  27. #include "ar256ex.h"
  28. //#include "ar256h2.cpp"
  29. extern screenmsgs s;
  30. extern mouse m;
  31. //extern char equal_flag;
  32.  
  33. int tweenturns();
  34. int frontend(int);
  35. void getname(int,int,int);
  36. int mark(int,int,int);
  37. int niceellipse(int,int,int,int);
  38. int bigtile(int,int,unsigned char far *,char,char);
  39. int ending();
  40. int ending2();
  41. int bossmsg();
  42. char * endalloc();
  43. void getstrengths();
  44.  
  45. void besilly(int);
  46. void dimthegreys();
  47.  
  48.  
  49.  
  50. frontend(int pl)
  51.  
  52.     {
  53.     char equal_flag=0;
  54.     FILE *in;
  55.     char *star,*are,*na;
  56.   int oldmx,oldmy;
  57.     char buf[4];
  58.     int i,j,ii,gotname=0,x,y,r;
  59.     signed char textx=8;
  60.     int cj=1,cursorx[30],cursory[30],cursorcol[30];
  61.     char *messages;char pmsgs[3];long timecounter=0,msgcounter=0;
  62.  
  63.     messages=(char *)malloc(900);
  64.     //pmsgs=(char *)malloc(21);
  65.     strcpy(messages,"                   ARENA v2.0 for DOS -- pure strategy\
  66.  in pure SVGA.  Written by Ben Peterson using love, patience \
  67. and lots of global variables :)      Why not register Arena \
  68. and get the single-player version?  Hours of pointless fun! \
  69. Aw, hell, all the things you can say in little scrolling \
  70. shareware messages have already been said.  Usually with \
  71. much better scrolling.  In fact, I bet nobody ever \
  72. reads this.  I bet you just thought: 'Hey, another scrolling \
  73. message.  Whee.' and clicked on 'play'.  But I have to write \
  74. SOMETHING here in this space I just allocated, don't I?                         ");
  75.     star=(char *)malloc(0x400);
  76.     are=(char *)malloc(0x400);
  77.     na=(char *)malloc(0x400);
  78.  
  79.  
  80.     in=fopen("star.dat","rb");
  81.     for (i=0;i<0x400;++i)
  82.         {
  83.         fscanf(in,"%c",&star[i]);
  84.         }
  85.     fclose(in);
  86.     in=fopen("are.dat","rb");
  87.     for (i=0;i<0x400;++i)
  88.         {
  89.         fscanf(in,"%c",&are[i]);
  90.         }
  91.     fclose(in);
  92.     in=fopen("na.dat","rb");
  93.     for (i=0;i<0x400;++i)
  94.         {
  95.         fscanf(in,"%c",&na[i]);
  96.         }
  97.     fclose(in);
  98.  
  99.  
  100.  
  101.      if (pl<2)pl=2;
  102.  
  103.         players=pl; // so that you get # of players = to cmd line names
  104.         pcol[0]=0x23;pcol[1]=0x2c;pcol[2]=0x3d;pcol[3]=0x39;
  105.         maxmon=29;
  106.         width=25;height=25;
  107.  
  108.     //setvisualpage(3);setactivepage(0);
  109.  
  110.         setfillpattern(pattern,0);
  111.         bar(0,0,640,250);
  112.  
  113.     m.unsetbounds();
  114.     m.wheremouse();
  115.     for(i=0;i<20;++i)
  116.         {
  117.         cursorx[i]=m.x;cursory[i]=m.y;
  118.         }
  119.     for(i=2;i<26;++i)
  120.         {cursorcol[i]=i%16;}
  121.  
  122.         cursorcol[0]=15,cursorcol[1]=15;  //set up cursor
  123.  
  124.     for(i=0;i<10;++i)
  125.         {
  126.         x=random(630),y=random(230);
  127.         bigtile(x,y,star,1,0);//color irrelevant
  128.         }
  129.  
  130.     setfillpattern(pattern,2);
  131.     bar(0,250,640,480);
  132.  
  133.  
  134.     for(i=0;i<20;++i)
  135.         {
  136.         r=random(20)+2;
  137.         bigtile(i*32,240,tile[r],1,random(15));
  138.         }
  139.     for(i=0;i<12;++i)
  140.         {
  141.         r=random(20)+2;
  142.         bigtile(i*64,260,tile[r],2,random(15));
  143.         }
  144.     for(i=0;i<10;++i)
  145.         {
  146.         r=random(20)+1;
  147.         bigtile(i*96,300,tile[r],3,random(15));
  148.         }
  149.     for(i=0;i<5;++i)
  150.         {
  151.         r=random(20)+2;
  152.         bigtile(i*128,360,tile[r],4,random(15));
  153.         }
  154.  
  155.  
  156.  
  157. /*    for(y=-240;y<240;++y)
  158.         {
  159.         for(x=-320;x<320;++x)
  160.             {
  161.             if(((x*x*5)+(y*y*5))%3)putpixel(x+320,y+240,2);
  162.             }
  163.         }
  164.                     */
  165.     setfillstyle(1,0);setcolor(0x0f);
  166.  
  167.     niceellipse(125,150,50,30);
  168.     niceellipse(125,250,50,30);
  169.     niceellipse(125,350,50,30);
  170.  
  171.     niceellipse(500,150,70,20);
  172.     niceellipse(500,225,70,20);
  173.     niceellipse(500,300,70,20);
  174.     niceellipse(500,375,70,20);
  175.  
  176.     bigtile(220,20,are,3,0); //write logo
  177.     bigtile(316,20,na,3,0);
  178.  
  179.  
  180.     for(i=0;i<4;++i)
  181.         {
  182.         setfillstyle(1,0);setcolor(0x0f);
  183.  
  184.         fillellipse(220+i*60,420,10,10);setcolor(pcol[i]);
  185.         outtextxy(217+i*60,417,itoa(i+1,buf,10));
  186.         for(j=0;j<72;j++)
  187.             {
  188.             setfillstyle(1,j+0x20);
  189.             bar(200+i*60,170+j*3,220+i*60,172+j*3);
  190.             }
  191.         setcolor(0x0f);
  192.         for(ii=0;ii<10;ii++)
  193.             {
  194.             setcolor(27-ii);
  195.             rectangle((200+i*60)-ii,170-ii,(220+i*60)+ii,382+ii);
  196.             }
  197.         }
  198.  
  199.  
  200.     setfillstyle(1,0);
  201.     bar(28*8,13*8,48*8,16*8+6);
  202.     for(i=0;i<5;++i)
  203.         {
  204.         setcolor(18+i);
  205.         rectangle(28*8-i,13*8-i,48*8+i,16*8+6+i);//the box the msgs are in
  206.         }
  207.     niceellipse(155,420,45,20);//play buttons
  208.     niceellipse(55,420,48,20);
  209.     niceellipse(570,420,40,20);//ballz
  210.     niceellipse(480,420,40,20);//UD_monsters
  211.     niceellipse(50,200,35,20); //sound
  212.     niceellipse(590,200,35,20);//nosound
  213.  
  214.  //    fillellipse(500,50,50,20);outtextxy(450,45,"Armies");
  215.  //    fillellipse(80,30,60,20);outtextxy(30,25,"No Illusions");
  216.  //    fillellipse(80,70,60,20);outtextxy(30,65,"No True Sight");
  217.  
  218.     setcolor(0xe);
  219.     outtextxy(90,145,"2 players");
  220.     outtextxy(90,245,"3 players");
  221.     outtextxy(90,345,"4 players");
  222.  
  223.     outtextxy(455,145,"Small arena");
  224.     outtextxy(455,220,"Normal arena");
  225.     outtextxy(455,295,"Large arena");
  226.     outtextxy(455,370,"Random arena");
  227.  
  228.     outtextxy(12,417,"RANDOM PLAY");
  229.     outtextxy(115,417,"EQUAL PLAY");
  230.     outtextxy(555,415,"Orbs");
  231.     outtextxy(465,415,"U.D.");
  232.     outtextxy(32,195,"Sound");
  233.     outtextxy(567,195,"Nosound");
  234.  
  235.  
  236.   setfillstyle(1,0);
  237.   bar(31,41,139,89);bar(501,41,609,89);
  238.     rectangle(40,48,130,61);outtextxy(42,51,"1:");outtextxy(58,51,pname[0]);
  239.     rectangle(40,68,130,81);outtextxy(42,71,"2:");outtextxy(58,71,pname[1]);
  240.     rectangle(510,48,600,61);outtextxy(512,51,"3:");outtextxy(528,51,pname[2]);
  241.     rectangle(510,68,600,81);outtextxy(512,71,"4:");outtextxy(528,71,pname[3]);
  242.  
  243.  
  244.     setcolor(0x0f);
  245.     for(i=0;i<15;++i)
  246.         {
  247.         setcolor(30-i);
  248.         rectangle(30-i,40-i,140+i,90+i);rectangle(500-i,40-i,610+i,90+i);
  249.         }                //draw name entering boxes
  250.  
  251.  
  252.  
  253.     moveto(m.x,m.y-17);setcolor(0x0c);
  254.     setwritemode(XOR_PUT);penty(2,0);setwritemode(0);//get rid of 1st mouse penty
  255.  
  256.  
  257.  
  258.  
  259.     //-----------MAIN LOOP MAIN LOOP MAIN     LOOP WOH YEAH!
  260.     for(;;)
  261.     {
  262.     while(m.wheremouse())
  263.         {
  264.         ++timecounter; // wraps around it's byte...
  265.  
  266.             textx--;if(textx<0)
  267.                 {                       //scroll procedure
  268.                 textx=8;
  269.                 ++msgcounter;if(msgcounter>610)msgcounter=0;
  270.                 }
  271.             bar(230,113,378,125);
  272.             //setcolor(0x07);
  273.             for(i=0;i<17;++i)
  274.                 {
  275.                 setcolor((msgcounter+i)%24+32);
  276.                 pmsgs[0]=*(messages+msgcounter+i);
  277.                 pmsgs[1]=0x00;
  278.                 outtextxy(233+textx+i*8,116,pmsgs);
  279.                 }
  280.  
  281.             bar(230,110,238,128);
  282.             bar(370,110,378,128);
  283.             //delay(5);
  284.  
  285.         if(kbhit())
  286.             {
  287.             if(getch()=='Q'){closegraph();besilly(1);}//quit! yeah!
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.             }
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.         if(players==2){mark(125,150,32);mark(125,250,0);mark(125,350,0);}
  302.         if(players==3){mark(125,150,0);mark(125,250,33);mark(125,350,0);}
  303.         if(players==4){mark(125,150,0);mark(125,250,0);mark(125,350,34);}
  304.         if(width==15){mark(500,150,35);mark(500,225,0);mark(500,300,0);mark(500,375,0);}
  305.         if(width==20){mark(500,150,0);mark(500,225,36);mark(500,300,0);mark(500,375,0);}
  306.         if(width==25){mark(500,150,0);mark(500,225,0);mark(500,300,37);mark(500,375,0);}
  307.         if(width==0){mark(500,150,0);mark(500,225,0);mark(500,300,0);mark(500,375,38);}
  308.         balls?mark(570,420,39):mark(570,420,0);
  309.         UD_MONSTERS?mark(480,420,40):mark(480,420,0);
  310.  
  311.         if((m.x!=oldmx)||(m.y!=oldmy))
  312.             {
  313.  
  314.             setwritemode(XOR_PUT);
  315.  
  316.             cursorx[26]=m.x,cursory[26]=m.y;
  317.             for(cj=1;cj<27;++cj)
  318.                 {
  319.                 setcolor(cursorcol[cj]);
  320.                 moveto(cursorx[cj],cursory[cj]-17);
  321.                 penty(2,0);
  322.  
  323.                 cursorx[cj-1]=cursorx[cj],cursory[cj-1]=cursory[cj],cursorcol[cj-1]=cursorcol[cj];
  324.                 cursorcol[26]=cursorcol[0];
  325.                 }
  326.         setwritemode(0);
  327.         oldmx=m.x;oldmy=m.y;
  328.  
  329.             }
  330.             else    //if head & tail not in same place, move cursor tail
  331.             {
  332.             if((cursorx[25]!=cursorx[1])||(cursory[25]!=cursory[1]))
  333.                 {
  334.                 setwritemode(XOR_PUT);
  335.  
  336.                 cursorx[26]=m.x,cursory[26]=m.y;
  337.                 for(cj=1;cj<27;++cj)
  338.                     {
  339.                     setcolor(cursorcol[cj]);
  340.                     moveto(cursorx[cj],cursory[cj]-17);
  341.                     penty(2,0);
  342.  
  343.                     cursorx[cj-1]=cursorx[cj],cursory[cj-1]=cursory[cj],cursorcol[cj-1]=cursorcol[cj];
  344.                     cursorcol[26]=cursorcol[0];
  345.  
  346.                     }
  347.                 }
  348.                 else   // if cursor not busy, delay
  349.                 {
  350.                 delay(7);
  351.                 }
  352.             setwritemode(0);
  353.             }
  354.         }
  355.  
  356.     if(range(125,150,m.x,m.y)<20){bip(4);players=2;}
  357.     if(range(125,250,m.x,m.y)<20){bip(5);players=3;}
  358.     if(range(125,350,m.x,m.y)<20){bip(6);players=4;}
  359.  
  360.     if(range(500,150,m.x,m.y)<20){bip(7);width=15;height=15;}
  361.     if(range(500,225,m.x,m.y)<20){bip(8);width=20;height=20;}
  362.     if(range(500,300,m.x,m.y)<20){bip(9);width=25;height=25;}
  363.     if(range(500,375,m.x,m.y)<20){bip(10);width=0;height=0;}
  364.  
  365.     if(range(50,200,m.x,m.y)<15){bip(3);noisy=1;}
  366.     if(range(590,200,m.x,m.y)<15){bip(3);noisy=0;}
  367.  
  368.     if(range(570,420,m.x,m.y)<15){risingbip(3);balls=balls^0x01;}
  369.     if(range(480,420,m.x,m.y)<15){risingbip(4);UD_MONSTERS=UD_MONSTERS^0x01;}
  370.  
  371.     if(range(42,55,m.x,m.y)<10){bip(5);getname(0,58,51);bip(6);}
  372.     if(range(42,75,m.x,m.y)<10){bip(6);getname(1,58,71);bip(7);}
  373.     if(range(512,55,m.x,m.y)<10){bip(7);getname(2,528,51);bip(8);}
  374.     if(range(512,75,m.x,m.y)<10){bip(8);getname(3,528,71);bip(9);}
  375.  
  376.     if((m.x<440)&&(m.x>200)&&(m.y<450)&&(m.y>170)&&(!gotname))
  377.         {                                            //setting colors
  378.  
  379.         i=((m.x-200)/60),j=(pcol[i]);
  380.         setfillstyle(1,j);
  381.         bar(205+i*60,170+(j-0x20)*3,215+i*60,172+(j-0x20)*3); //erase old marker
  382.  
  383.         j=((m.y-170)/3)+0x20;           // first 32 colors not available
  384.         //printf("%d %d",pcol[i],j);
  385.         pcol[i]=j;
  386.         bip(8+(j/4));
  387.         setfillstyle(1,0);
  388.         bar(205+i*60,170+(j-0x20)*3,215+i*60,172+(j-0x20)*3);   //draw new one
  389.         setcolor(j);settextstyle(0,0,1);
  390.         outtextxy(217+i*60,417,itoa(i+1,buf,10));
  391.         }
  392.     if(range(155,420,m.x,m.y)<15){equal_flag=1;
  393.     break;} //play. woo.
  394.     if(range(55,420,m.x,m.y)<15){equal_flag=0;
  395.     break;}
  396.     gotname=0;
  397.  
  398.     }
  399.     if(!width)width=random(20)+10,height=random(20)+10;
  400.     pstartx[0]=4,pstartx[1]=width-5,pstartx[2]=width-5,pstartx[3]=4;
  401.     pstarty[0]=4,pstarty[1]=height-5,pstarty[2]=4,pstarty[3]=height-5;
  402.     for(i=0;i<players;++i)
  403.         {
  404.         isalive[i]=1;
  405.         pgraph[i]=random(3);
  406.         if (pgraph[i]==1)pgraph[i]=1;
  407.         if (pgraph[i]==2)pgraph[i]=23;
  408.         }
  409.     setfillstyle(1,0);bar(0,0,640,480);
  410.  
  411.     free(messages);
  412.     free(star);free(are);free(na);
  413.  
  414.     if(NOT_REGD)UD_MONSTERS=0;
  415.   
  416.     return(equal_flag);
  417.  
  418. }
  419.  
  420. void getname(int player,int x,int y)
  421.     {
  422.     char chars,c[2],ccol; // c is pointer for benefit of outtextxy
  423.     int i;
  424.     moveto(m.x,m.y-17);setcolor(0x0e);  //blank mouse cursor(?)
  425.     setwritemode(XOR_PUT);penty(2,0);
  426.     setfillstyle(1,0);settextstyle(0,0,1);
  427.     bar(x,y,x+62,y+8);
  428.  
  429.     while(chars<8)
  430.         {
  431.         ++ccol;
  432.         setcolor(ccol%16);
  433.         rectangle(x+chars*8,y-2,8+x+chars*8,y+9);delay(5);
  434.         rectangle(x+chars*8,y-2,8+x+chars*8,y+9);
  435.         setcolor(pcol[player]);
  436.         if(kbhit())
  437.             {
  438.             *c=getch();c[1]=0x00; //dont forget to terminate string!
  439.             if((*c>0x19)&&(*c<0x7f))//if a printable thang
  440.                 {
  441.                 pname[player][chars]=*c;
  442.                 outtextxy(x+chars*8,y,c);
  443.                 ++chars;
  444.                 }
  445.             if((*c==0x08)&&(chars)) // if delete
  446.                 {
  447.                 --chars;
  448.                 bar(x+chars*8,y,x+8+chars*8,y+8);
  449.                 pname[player][chars]=0x20;
  450.                 }
  451.             if(*c==0x0d)      // if CR
  452.                 {
  453.                 for(i=chars;i<9;++i)
  454.                     {
  455.                     pname[player][i]=0x00;   //dont forget etc etc
  456.                     }
  457.                 break;
  458.                 }
  459.             }
  460.         }
  461.     moveto(m.x,m.y-17);setcolor(0x0e);  //blank mouse cursor(?)
  462.     penty(2,0);
  463.     setwritemode(0);pname[player][8]=0x00;
  464. }
  465.  
  466.  
  467. niceellipse(int x,int y,int xrad, int yrad)
  468.     {
  469.     float i;
  470.     fillellipse(x,y,xrad,yrad);
  471.     for (i=0;i<3;i++)
  472.         {
  473.         setcolor(27-i);
  474.         ellipse(x,y,0,360,xrad+i,yrad+i);
  475.         }
  476.     setcolor(0x07);
  477.     return(23);
  478. }
  479.  
  480.  
  481.  
  482.  
  483. mark(int x,int y,int col)
  484.     {
  485.     y+=3;
  486.     int tick[10];
  487.     tick[0]=x-21,tick[1]=y+3,tick[2]=x,tick[3]=y+9,tick[4]=x+21,
  488.     tick[5]=y+3,tick[6]=x,tick[7]=y+15,tick[8]=x-21,tick[9]=y+3;
  489.     setlinestyle(0,0,3);setcolor(col);
  490.     //m.offmouse();
  491.     drawpoly(5,tick);
  492.  
  493.     //m.onmouse();
  494.     setlinestyle(0,0,1);
  495.  
  496.     return(0);
  497. }
  498.  
  499. bigtile (int tilex,int tiley,unsigned char far *which,char size,char c)
  500.     {
  501.     int i,px,py;
  502.     //if(tile[which][1]!=3)return(1);
  503.         for (i=0;i<0x400;++i)
  504.             {
  505.             px=tilex+(i % 32)*size;py=tiley+(i / 32)*size;
  506.             if (which[i] < 0xfe)
  507.                 {
  508.                 setfillstyle(1,which[i]);
  509.                 bar(px,py,px+size,py+size);
  510.                 }
  511.             if (which[i]==0xfe)
  512.                 {
  513.                 setfillstyle(1,c);
  514.                 bar(px,py,px+size,py+size);
  515.                 }
  516.             }
  517.     return(0);
  518. }
  519.  
  520. char *endalloc()
  521.     {
  522.     char *skulptr;FILE *in;int i;
  523.     skulptr=(char *)malloc(0x400);
  524.     in=fopen("skull.dat","rb");
  525.     for (i=0;i<0x400;++i)
  526.         {
  527.         fscanf(in,"%c",&skulptr[i]);
  528.         }
  529.     fclose(in);
  530.     return(skulptr);
  531. }
  532.  
  533. endingtwo()
  534.     {
  535.     char *skull=(char *)endalloc();
  536.  
  537.  
  538.     setfillstyle(0,1);setcolor(0x07);setlinestyle(0,0,3);
  539.     settextstyle(0,0,3);
  540.     bar(100,100,540,330);
  541.     rectangle(100,100,540,330);
  542.     outtextxy(160,110,"What Lunacy!!");
  543.     settextstyle(0,0,1);
  544.     outtextxy(110,180,"All the wizards in the game have been destroyed in");
  545.     outtextxy(110,190,"their childish and futile squabbling.  Justice and");
  546.     outtextxy(110,200,"Truth hang their heads as they view the disaster. When");
  547.     outtextxy(110,210,"oh when will people ever learn?");
  548.     bigtile(250,230,skull,3,0);
  549.     getch();
  550.  
  551.  
  552.     s.bargraph(luck_history,"rolled his dice;","Overall player luck:");
  553.  
  554.     s.graph(tree_history,"defoliated his domain;","Trees standing in any given turn:");
  555.     s.graph(attack_history,"reaped his harvest;","Attack power used in any given turn:");
  556.     s.graph(strength_history,"allotted his gifts;","Strength of players by turn:");
  557.     //dimthegreys();
  558.     closegraph();clrscr();m.unsetbounds();
  559.     besilly(1);
  560.  
  561.  
  562. }
  563. ending()
  564.     {
  565.     int px,py,i,st;char buf[3];char *skull=(char *)endalloc();
  566.  
  567.  
  568.     for(i=0;i<players;++i)
  569.         {
  570.         if(isalive[i]){curpla=i;break;}
  571.         }
  572.  
  573.     setfillstyle(0,1);setcolor(0x07);setlinestyle(0,0,3);
  574.     bar(100,100,540,380);
  575.     rectangle(100,100,540,380);
  576.     bigtile(110,110,tile[mon[curpla][0].graphic],2,pcol[curpla]);
  577.     settextstyle(0,0,3);setcolor(pcol[curpla]);
  578.     outtextxy(175,140,pname[curpla]);
  579.     setcolor(0x07);
  580.     settextstyle(0,0,2);
  581.     outtextxy(110,190,"Is the sole survivor!");
  582.     settextstyle(0,0,1);
  583.  
  584.     outtextxy(110,220,"I guess that means we have a winner!");
  585.     px=336-moncounter[curpla]*32,py=240; //+16 cos not show wiz
  586.     setfillpattern(pattern,0x02);
  587.     bar(px-4,py-4,px+moncounter[curpla]*64-64,py+80);//-64 because of not showing wiz.
  588.     setfillstyle(1,0);
  589.     bar(px-4,py+62,px+moncounter[curpla]*64-64,py+72);
  590.     rectangle(px-4,py-4,px+moncounter[curpla]*64-64,py+80);
  591.  
  592.     for (i=1;i<moncounter[curpla];++i)
  593.         {
  594.         bigtile(px+64*(i-1),py,tile[mon[curpla][i].graphic],2,pcol[curpla]);
  595.         st=mon[curpla][i].status;
  596.  
  597.         if(st==0)outtextxy(px+64*i-64,py+64,"  Gone");
  598.         if(st==1)outtextxy(px+64*i-64,py+64,"  Alive");
  599.         if(st==2)outtextxy(px+64*i-64,py+64,"Illusion");
  600.         if(st==3)outtextxy(px+64*i-64,py+64," Undead");
  601.         if(st==0x11)outtextxy(px+64*(i-1),py+64," Shade");
  602.  
  603.         }
  604.     settextstyle(0,0,2);
  605.     outtextxy(110,330,"Successful acts of mayhem:");
  606.     settextstyle(0,0,1);
  607.     for (i=0;i<players;++i)
  608.         {
  609.         px=130+i*100,py=350;setcolor(pcol[i]);
  610.         outtextxy(px,py,pname[i]);outtextxy(px+70,py,itoa(kills[i],buf,10));
  611.         }
  612.     getch();
  613.  
  614.     s.bargraph(luck_history,"rolled his dice;","Overall player luck:");
  615.     s.graph(tree_history,"treated the trees;","Trees standing per turn:");
  616.     s.graph(attack_history,"reaped his harvest;","Attack power used per turn:");
  617.     s.graph(strength_history,"weighed souls in the balance;","Strength of players by turn:");
  618.  
  619.  
  620.     setfillstyle(1,0);
  621.  
  622.     bar(0,0,639,479);
  623.     bigtile(250,130,skull,4,0);
  624.     settextstyle(0,0,2);
  625.     setcolor(0x7b);
  626.     outtextxy(320-strlen(pname[curpla])*8,280,pname[curpla]);
  627.     settextstyle(0,0,1);
  628.     outtextxy(190,300,"Is the victor... until next time...");
  629.     getch();
  630.     dimthegreys();
  631.  
  632.     closegraph();
  633.     clrscr();m.unsetbounds();
  634.     besilly(1);
  635. }
  636.  
  637. tweenturns(void)
  638.     {
  639.     int i,j,ii,jj;
  640.     thisturn++;
  641.     for(curpla=0;curpla<players;++curpla)
  642.         {
  643.         if (isalive[curpla])
  644.         {
  645.         if ((mon[curpla][0].status==0x11)||(mon[curpla][0].status==0))
  646.             {
  647.             s.decho(curpla);
  648.             for(i=0;i<maxmon;++i)
  649.                 {
  650.                 mon[curpla][i].status=0;
  651.                 sq[mon[curpla][i].x][mon[curpla][i].y].whatside=0xff;
  652.                 }
  653.             isalive[curpla]=0;
  654.  
  655.             }
  656.  
  657.         }
  658.         }
  659.     curpla=4; // this is for mirkwoods
  660.     getstrengths();
  661.  
  662.     i=isalive[0]+isalive[1]+isalive[2]+isalive[3];
  663.  
  664.     if(i==1){thisturn++;getstrengths();ending();} // a new lot of strengths are got, so that newly dead wizzes have zeros on the graph
  665.     if(i==0){thisturn++;getstrengths();endingtwo();}
  666.  
  667.     for(i=0;i<width;++i)
  668.         {
  669.         for(j=0;j<height;++j)
  670.             {
  671.             if((sq[i][j].land==5)&&(sq[i][j].whose!=5))
  672.                 {
  673.                 for(ii=0;ii<3;++ii)
  674.                     {
  675.                     for(jj=0;jj<3;++jj)
  676.                         {
  677.                         if((i+ii-1>-1)&&(i+ii-1<width)&&(j+jj-1>-1)&&(j+jj-1<height))
  678.                             {
  679.                             if((sq[i+ii-1][j+jj-1].whatside!=0xff)&&(sq[i+ii-1][j+jj-1].land!=1)&&(sq[i+ii-1][j+jj-1].land!=10))
  680.                                 {
  681.                                 if(decide(3,mon[sq[i+ii-1][j+jj-1].whatside][sq[i+ii-1][j+jj-1].whatmonster].defend))
  682.                                     {
  683.                                     drawmap(i,j);
  684.                                     setfillstyle(1,0);bar(482,297,638,351);
  685.                                     rectangle(482,297,638,351);
  686.                                     downbip(1);
  687.                                     outtextxy(485,300,"The vile Mirkwoods");outtextxy(485,310,"Consume a");
  688.                                     setcolor(pcol[sq[i+ii-1][j+jj-1].whatside]);
  689.                                     outtextxy(485,320,mon[sq[i+ii-1][j+jj-1].whatside][sq[i+ii-1][j+jj-1].whatmonster].name);
  690.  
  691.  
  692.                                     mon[sq[i+ii-1][j+jj-1].whatside][sq[i+ii-1][j+jj-1].whatmonster].status=0;
  693.                                     sq[i+ii-1][j+jj-1].whatside=0xff;
  694.  
  695.  
  696.                                     curx=i,cury=j;foom(i+ii-1,j+jj-1);getch();
  697.                                     }
  698.                                 }
  699.                             }
  700.                         }
  701.                     }
  702.                 }    //whee! what fun it is, checking for mirkwood victories!
  703.             }
  704.         }
  705.  
  706.  
  707.  
  708.  
  709.     for(i=0;i<width;++i)                // ages mwoods so they cant attack right after creation
  710.         {
  711.         for(j=0;j<height;++j)
  712.             {
  713.             if(sq[i][j].whose==5)sq[i][j].whose=0;
  714.             }
  715.         }
  716.  
  717.  
  718.     for(i=0;i<width;++i)
  719.         {
  720.         for(j=0;j<height;++j)
  721.             {
  722.             if(sq[i][j].land==7)
  723.                 {
  724.                 for(ii=0;ii<3;++ii)
  725.                     {
  726.                     for(jj=0;jj<3;++jj)
  727.                         {
  728.                         if((i+ii-1>-1)&&(i+ii-1<width)&&(j+jj-1>-1)&&(j+jj-1<height))
  729.                             {
  730.                             if((sq[i+ii-1][j+jj-1].whatside!=0xff)&&(sq[i+ii-1][j+jj-1].land<10))
  731.                                 {
  732.                                 if(mon[sq[i+ii-1][j+jj-1].whatside][sq[i+ii-1][j+jj-1].whatmonster].immunities==3)
  733.                                     {
  734.                                     continue; //dont hit fire resistors
  735.                                     }
  736.                                 if(decide(3,mon[sq[i+ii-1][j+jj-1].whatside][sq[i+ii-1][j+jj-1].whatmonster].defend))
  737.                                     {
  738.                                     sq[i+ii-1][j+jj-1].land=7;
  739.                                     drawmap(i,j);
  740.                                     setfillstyle(1,0);bar(482,297,638,351);
  741.                                     rectangle(482,297,638,351);
  742.                                     downbip(1);
  743.                                     outtextxy(485,300,"Sparks leap onto");outtextxy(485,310,"a");
  744.                                     setcolor(pcol[sq[i+ii-1][j+jj-1].whatside]);
  745.                                     outtextxy(500,310,mon[sq[i+ii-1][j+jj-1].whatside][sq[i+ii-1][j+jj-1].whatmonster].name);
  746.  
  747.                                     mon[sq[i+ii-1][j+jj-1].whatside][sq[i+ii-1][j+jj-1].whatmonster].status=0;
  748.                                     sq[i+ii-1][j+jj-1].whatside=0xff;
  749.                                     curx=i,cury=j;foom(i+ii-1,j+jj-1);getch();
  750.                                     }
  751.                                 }
  752.                             if(sq[i+ii-1][j+jj-1].land==6)
  753.                                 {       //if no monster but grass make fire
  754.                                 if(!random(2))sq[i+ii-1][j+jj-1].land=8;
  755.                                 }
  756.                             }
  757.                         }
  758.                     }
  759.                 }    //whee! what fun it is, checking for fires that jump onto monsters
  760.             }      //and onto grasslands
  761.         }
  762.  
  763.     for(i=0;i<width;++i)
  764.         {
  765.         for(j=0;j<height;++j)
  766.             {
  767.             if(sq[i][j].land==7)    //put out fires that have been burning.
  768.                 {
  769.                 sq[i][j].land=0;
  770.                 }
  771.             }
  772.         }
  773.  
  774.     for(i=0;i<width;++i)
  775.         {
  776.         for(j=0;j<height;++j)
  777.             {
  778.             if(sq[i][j].land==8)    //age other fires.
  779.                 {
  780.                 sq[i][j].land=7;
  781.                 }
  782.             }
  783.         }
  784.  
  785.  
  786.  
  787.  
  788.     for(i=0;i<width;++i)
  789.         {
  790.         for(j=0;j<height;++j)
  791.             {
  792.             if(sq[i][j].land==6)
  793.                 {
  794.                 for(ii=0;ii<3;++ii)
  795.                     {
  796.                     for(jj=0;jj<3;++jj)
  797.                         {
  798.                         if((i+ii-1>-1)&&(i+ii-1<width)&&(j+jj-1>-1)&&(j+jj-1<height))
  799.                             {
  800.                             if((!random(32))&&(!sq[i+ii-1][j+jj-1].land))
  801.                                 {
  802.                                 sq[i+ii-1][j+jj-1].land=6;
  803.                                 }
  804.                             }
  805.                         }
  806.                     }
  807.                 }    //whee! what fun it is checking for spreading grass!
  808.             }
  809.         }
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816. return(0);
  817. }
  818.  
  819.  
  820. void besilly(int quit)
  821.     {
  822.     int i,j;char length;
  823.     clrscr();
  824.  
  825.     textbackground(4);
  826.     cprintf("That was:                                                                      \n\r");
  827.     textcolor(9+BLINK);textbackground(7);
  828.     cprintf("                             ARENA v2.0 for DOS                                \n\r");
  829.     textcolor(WHITE);textbackground(4);
  830.   cprintf("                                                                               \n\r");
  831.   cprintf("                                                                               \n\r");
  832.   //cprintf("                                                                               \n\r");
  833.  
  834.  
  835.     cprintf("        Register");
  836.  
  837.     textcolor(LIGHTRED);
  838.     cprintf(" Arena for the laughable price of just 10 pounds or            \n\r");
  839.     cprintf("        15 dollars -- and recieve the single-player version with               \n\r");
  840.     cprintf("        it's choice of malicious yet intriguing AI opponents and it's          \n\r");
  841.     cprintf("        monster editor.                                                        \n\r");
  842.     textcolor(7);
  843.     cprintf("        For instructions on registering, see the accompanying                  \n\r");
  844.     cprintf("        ARENA.TXT file.  You can email me at:                                  \n\r");
  845.   cprintf("                                                                               \n\r");
  846.  
  847.  
  848.     textcolor(9);
  849.     cprintf("                  azathoth@zippy.spods.dcs.kcl.ac.uk                           \n\r");
  850.   cprintf("                                                                               \n\r");
  851.  
  852.     textcolor(7);
  853.     cprintf("        for a detailed discussion of this game and it's concepts,              \n\r");
  854.     cprintf("        or just to say hi.                                                     \n\r");
  855.   cprintf("                                                                               \n\r");
  856.  
  857.     cprintf("        By the way, if you use POV-Ray, check out STEERPIKE'S                  \n\r");
  858.     cprintf("        tutorial available at ftp.povray.org!  It's really good.               \n\r");
  859.     cprintf("                                                                               \n\r");
  860.  
  861.     textbackground(7);textcolor(9);
  862.     cprintf("        Press something to quit...                                             \n\r");
  863.  
  864.  
  865.  
  866.     textcolor(7);textbackground(4);
  867.     cprintf("                                                                               \n\r");
  868.     cprintf("                                                                               \n\r");
  869.  
  870.  
  871.     //cprintf("\n\r");
  872.     textbackground(0);
  873.     getch();
  874.     for(i=0;i<24;++i)
  875.         free (tile[i]);
  876.     for(i=0;i<8;++i)
  877.         {free (shroom[i]);free (terrt[i]);}
  878.     exit(0);
  879.     }
  880.  
  881. bossmsg()
  882.     {
  883.     //system("dir");
  884.     system("mem /c /p");
  885.     return(1);
  886. }
  887.  
  888. void dimthegreys()
  889.     {
  890.     int i,j,ii,c=63;
  891.     if (random(3))     // OI!!!!!
  892.         {
  893.         for(i=8;i>-32;i-=3 )
  894.             {
  895.             for(j=0;j<16;++j)
  896.                 {
  897.                 c=i+j*3;if((c>253)||(c<0))c=0;
  898.                 setrgbpalette(j+16,c,c,c);
  899.                 }
  900.             }
  901.         }
  902.     else
  903.         {
  904.         for(ii=0;ii<16;++ii)
  905.             {
  906.             delay(50);
  907.             for(i=250;i<128+250;++i)
  908.                 {
  909.                 for(j=130;j<130+128;++j)
  910.                     {
  911.                     c=getpixel(i,j);
  912.                     if(c>16)putpixel(i,j,--c);
  913.                     }
  914.                 }
  915.             }
  916.         }
  917.  
  918. }
  919.  
  920. void getstrengths()
  921.     {
  922.     int i,j,num;
  923.     for(i=0;i<players;++i)
  924.         {
  925.         num=0;
  926.         for(j=0;j<moncounter[i];++j)
  927.             {
  928.             num+=mon[i][j].power();
  929.             }
  930.  
  931.  
  932.         strength_history[i][thisturn]=num;
  933.  
  934.         }
  935.  
  936.  
  937.  
  938.     for(i=0;i<width;++i)
  939.         {
  940.         for(j=0;j<height;++j)
  941.             {
  942.             if(sq[i][j].land==1)
  943.                 {
  944.                 tree_history[sq[i][j].whose][thisturn]+=5;
  945.                 }
  946.             }
  947.         }
  948. }